import urllib.request
import urllib.parse
location = input("城市:")
# 拼接url
url = "http://www.baidu.com/s?wd=" + urllib.parse.quote(location+'天气')
# 请求读取
page_source = urllib.request.urlopen(url).read().decode("utf-8").replace("\n", "").replace("\r", "")

weather = page_source.split('<p class="op_weather4_twoicon_weath"')[1].split('title="">')[1].split('</p>')[0].strip()
temp = page_source.split('<p class="op_weather4_twoicon_temp">')[1].split('</p>')[0].strip()
print(weather,temp)

